<?php
if(!defined('IN_IBEIKE')){
	exit('Access Denied');
}

class table_common_notify extends common_table{
	public function __construct(){
		$this->_table='common_notify';
		$this->_pk='nid';
		parent::__construct();
	}
	public function count_by_uid_readtime($uid,$readtime){
		if(isset($uid)&&isset($readtime)){
			$res=DB::query('select * from %t where fromid=%d and readtime<%d',array($this->_table,$uid,$readtime));
			return DB::num_rows($res);
		}else{
			return false;
		}
	}
	public function fetch_by_uid_readtime($uid,$readtime){
		
	}
	public function fetch_all_by_nid($nid){
		if(!empty($nid)&&$nid){
			return DB::fetch_all('SELECT * FROM %t WHERE nid=%s',array($this->_table,$nid));//返回数组包含各个字段的值
		}
		return false;
	}
	public function take_new_info($toid){
		if(!empty($toid)){
			$link= DB::fetch_all("SELECT * FROM %t WHERE toid=%d and readed=0",array($this->_table,$toid));//获取没有读过的信息的数目
		    return DB::num_rows($link);
		}else{
			return false;
		}
	}
}
?>